When I try to compile my code I get this message
Code:
fig06_21.c: In function `main':
fig06_21.c:12: warning: passing arg 1 of `printArray' from incompatible pointer type
fig06_21.c:15: warning: passing arg 1 of `printArray' from incompatible pointer type
fig06_21.c:18: warning: passing arg 1 of `printArray' from incompatible pointer type
I copied the example straight from the book I have no idea what the problem is. I imagine it has something to do with the arrays.
Code:
#include <stdio.h>
void printArray( const int[][ 3 ] );
int main()
{
int array1[ 2 ][ 3 ] = { { 1, 2, 3 }, { 4, 5, 6 } },
array2[ 2 ][ 3 ] = { 1, 2, 3, 4, 5 },
array3[ 2 ][ 3 ] = { { 1, 2}, { 4 } };
printf("Values in array1 by row are:\n");
printArray( array1 );
printf("Values in array2 by row are:\n");
printArray( array2 );
printf("Values in array3 by row are:\n" );
printArray( array3 );
return 0;
}
void printArray( const int a[][ 3 ] )
{
int i, j;
for (i = 0; i <= 1; i++ ) {
for (j = 0; j <= 2; j++)
printf("%d ", a[ i ][ j ] );
printf("\n");
}
}